Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Aug 20, 2025

Summary

This PR fixes an issue where test data used inside an IN clause was unintentionally broken into multiple lines during SQL formatting.

Relation

#397

Details

  • Implemented a dedicated IN clause group block so that IN clauses are explicitly recognized and formatted correctly.
  • Added a function to determine whether a conditional directive is positioned before its parent block.
  • Updated the parent-child relationship logic for conditional directives so that their positions are correctly identified. This ensures proper control over when line breaks should or should not be applied.

Impact

  • Prevents unwanted line breaks in IN clause test data.
  • Ensures consistent formatting of SQL containing conditional directives, avoiding misaligned or unnecessary newlines.

@xterao xterao added this to the 2.1.2 Release milestone Aug 20, 2025
@xterao xterao requested a review from Copilot August 20, 2025 11:06
@xterao xterao self-assigned this Aug 20, 2025
@github-actions github-actions bot added the fix Bug fixes label Aug 20, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes IN clause formatting issues by implementing dedicated handling for conditional directives in SQL formatting, ensuring that test data in IN clauses maintains proper formatting without unwanted line breaks.

  • Introduced a dedicated SqlInGroupBlock to explicitly handle IN clause formatting
  • Added a method to determine conditional directive positioning relative to parent blocks
  • Updated parent-child relationship logic for conditional directives to ensure proper formatting control

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
SqlFormatterTest.kt Added new test methods for conditional clause formatting scenarios
SqlBlockGenerator.kt Added generation logic for IN group blocks and WHERE group blocks
NotQueryGroupHandler.kt Updated IN keyword detection and function/alias context handling
SqlBlockRelationBuilder.kt Enhanced parent-child relationship handling for conditional directives
SqlInGroupBlock.kt New dedicated block class for handling IN clause formatting
SqlWhereGroupBlock.kt New WHERE group block implementation
Various test data files Test cases demonstrating proper conditional directive formatting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@xterao xterao merged commit b6ad4c1 into fix/sql-formatter Aug 21, 2025
5 checks passed
@xterao xterao deleted the fix/sql-format-in-group-line-breaks branch August 21, 2025 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Line Break Formatting in Subgroups Within Conditional Directives

2 participants